home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1993 September / September 93.iso / Archives / Utilities / Text / EnToutesLettres / ETL.DevDoc / VlaamsCode.c < prev   
C/C++ Source or Header  |  1991-11-29  |  4KB  |  188 lines

  1. #include <SetUpA4.h>
  2.  
  3. static    char unites[10][8] = { "nul","een","twee","drie","vier","vijf","zes","zeven","acht","negen" }    ;
  4. static    char dizaines[10][14] = { "","tien","twintig","dertig","veertig","vijftig","zestig","zeventig","tachtig","negentig" }    ;
  5. static     char multiples[4][9] = { "honderd","duizend","miljoen" ,"miliard"}    ;
  6. static     char special[10][10] = { "tien","elf","twaalf","dertien","veertien","vijftien","zestien","zeventien","achtien","negentien"}    ;
  7.  
  8. char    *strcpy(char *s1,char *s2)    ;
  9. char    *strcat(char *s1,char *s2)    ;
  10. void    reverse(char *s)    ;
  11. short    strlen(char *s)    ;
  12. short    dutch(char *temp,char *tmpresult,short n)    ;
  13.  
  14. pascal void Debugger(void)
  15.     = 0xA9FF; 
  16.  
  17. pascal void main(char *text,char * result)
  18. {
  19.     char    thestring[20],temp[4],tmpresult[256];
  20.     short    i,j,l,res        ;
  21.     short    plurial            ;
  22.     
  23.         RememberA0()        ;
  24.         SetUpA4()            ;
  25.         text[12] = 0        ;    /* max =  999 999 999 999 */
  26.         result[0] = '\0'    ;
  27.         (void)strcpy(thestring,text)    ;
  28.         if( strlen(thestring) != 0 )
  29.         {
  30.             while (thestring[0] == '0')
  31.                 for (i=0;thestring[i]!=0;thestring[i]=thestring[i+1],i++)    ;
  32.             plurial = 0 ;
  33.             if ( (l = strlen(thestring)) )
  34.             {
  35.                 reverse(thestring)    ;
  36.                 if (l < 12)
  37.                 {
  38.                     for ( i=l ; i<12 ; i++ )
  39.                         thestring[i] = '0'    ;
  40.                     thestring[12] = 0    ;
  41.                 }
  42.                 for ( i=3 ; i>=0 ; i--)
  43.                 {
  44.                     for ( j=3*i ; j<3*(i+1) ; j++)
  45.                         temp[j-3*i] = thestring[j]    ;
  46.                     temp[3] = 0         ;
  47.                     tmpresult[0] = 0    ;
  48.                     res = dutch(temp,tmpresult,i)    ;
  49.                     if ( (res > 1) || ((res == 1) && (i != 0)) )
  50.                         plurial = 1    ;
  51.                     strcat(result,tmpresult)        ;
  52.                 }
  53.             }
  54.             else
  55.                 strcpy(result,unites[0])    ;
  56.         }
  57.         RestoreA4()    ;
  58. }    
  59.  
  60. short dutch(char *temp,char *tmpresult,short n)
  61. {
  62.     register int res,x,y,z;
  63.  
  64.     reverse(temp);
  65.     x=temp[0]-'0';
  66.     y=temp[1]-'0';
  67.     z=temp[2]-'0';
  68.     res=((x*10)+y)*10+z;
  69.     if(res!=0)
  70.         {
  71.         if((x==0)&&(y==0)&&(z==0))
  72.             return;
  73.         if(x>1)
  74.             {
  75.             strcat(tmpresult," ");
  76.             strcat(tmpresult,unites[x]);
  77.             strcat(tmpresult,multiples[0]);
  78.             }
  79.         if(x==1)
  80.             {
  81.             strcat(tmpresult," ");
  82.             strcat(tmpresult,multiples[0]);
  83.             }
  84.         if(y==0)
  85.             {
  86.             if(z>1)
  87.                 {
  88.                 strcat(tmpresult," ");
  89.                 strcat(tmpresult,unites[z]);
  90.                 }
  91.             else
  92.                 if(z==1)
  93.                     if((n==1)&&(x==0))
  94.                         strcat(tmpresult," ");
  95.                     else
  96.                         {
  97.                         strcat(tmpresult," ");
  98.                         strcat(tmpresult,unites[z]);
  99.                         }
  100.             }
  101.         else
  102.             {
  103.             if(y==1)
  104.                 {
  105.                 strcat(tmpresult," ");
  106.                 strcat(tmpresult,special[z]);
  107.                 }
  108.             else
  109.                 {
  110.                 if(z==0)
  111.                     {
  112.                     strcat(tmpresult," ");
  113.                     strcat(tmpresult,dizaines[y]);
  114.                     }
  115.                 else
  116.                     {
  117.                     strcat(tmpresult," ");
  118.                     strcat(tmpresult,unites[z]);
  119.                     if((z==2)||z==3)
  120.                         strcat(tmpresult,"ën");
  121.                     else
  122.                         strcat(tmpresult,"en");
  123.                     strcat(tmpresult,dizaines[y]);
  124.                     }
  125.                 }
  126.             }
  127.         if(n)
  128.             {
  129.             if(((x!=0)&&((y!=0)||(z!=0))&&(n==1))||(n>1))
  130.                 strcat(tmpresult," ");
  131.             strcat(tmpresult,multiples[n]);
  132.             }
  133.         }
  134.     return(res);
  135.     }
  136.             
  137.             
  138. char * strcpy(char *s1,char *s2)
  139. {
  140.     asm {
  141.         movea.l    s1,a0        ;  A0 = s1
  142.         movea.l    s2,a1        ;  A1 = s2
  143.         move.l    a0,d0            ;  D0.L = result
  144. @1        move.b    (a1)+,(a0)+
  145.         bne.s    @1
  146.     }
  147. }
  148.  
  149.  
  150. char *strcat(char *s1,char *s2)
  151. {
  152.     asm {
  153.         movea.l    s1,a0        ;  A0 = s1
  154.         movea.l    s2,a1        ;  A1 = s2
  155.         move.l    a0,d0            ;  D0.L = result
  156. @1        tst.b    (a0)+
  157.         bne.s    @1
  158.         subq.l    #1,a0
  159. @2        move.b    (a1)+,(a0)+
  160.         bne.s    @2
  161.     }
  162. }
  163.  
  164. short strlen(char *s)
  165. {
  166.     asm {
  167.         moveq    #-1,d0            ;  D0.L = result
  168.         movea.l    s,a0        ;  A0 = s
  169. @1        addq.l    #1,d0
  170.         tst.b    (a0)+
  171.         bne.s    @1
  172.     }
  173. }
  174.  
  175. void reverse(char *s)
  176. {
  177.     register short        i,j        ;
  178.     register char        c        ;
  179.         
  180.         for(i=0,j=strlen(s)-1;i<j;i++,j--)
  181.         {
  182.             c = s[j]            ;
  183.             s[j] = s[i]            ;
  184.             s[i] = c            ;
  185.         }
  186. }
  187.  
  188.